import Vue from 'vue'
import App from './App.vue'
import router from './router/router.js'
import './plugins/element.js'
import "./assets/css/global.css"
import "./assets/fonts/iconfont.css"
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'

Vue.config.productionTip = false
axios.defaults.baseURL="http://127.0.0.1:8888/api/private/v1/"



// 添加请求拦截器
axios.interceptors.request.use(function (config) {
  // 在发送请求之前做些什么
  
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
}, function (error) {
  // 对请求错误做些什么 
  console.log("==拦截发送请求==error==>");
  console.log (error.data);
  return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
  // 对响应数据做点什么 
  console.log("==拦截响应数据请求==>" + JSON.stringify(response.data)); 
  // return response;
  return response.data;
}, function (error) {
  // 对响应错误做点什么
  console.log("==拦截响应数据请求==error==>" + JSON.stringify(error)); 
  return Promise.reject(error);
});

Vue.prototype.$httpReq = axios
 
Vue.component('tree-table', ZkTable)
new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
